package au.org.ala.collectors

/**
 * Created by IntelliJ IDEA.
 * User: markew
 * Date: 6/04/11
 * Time: 11:26 AM
 * To change this template use File | Settings | File Templates.
 */
class Utils {

    static mixedCase(String str) {
        switch (str?.size()) {
            case 0: return ""
            case 1: return str.toUpperCase()
            default:
                // uppercase first letter plus any that follow a hyphen
                def parts = str.tokenize('-')
                def res = parts.collect {
                    if (it.size() > 1) {
                        it = it[0].toUpperCase() + it[1..-1].toLowerCase()
                    }
                    it
                }.join('-')

                return res
        }
    }
}
